package com.test;

/**
 * Created with IntelliJ IDEA.
 * User: xianfei
 * Date: 15-12-25
 * Time: 上午10:32
 * To change this template use File | Settings | File Templates.
 */

public class InterviewQuestion {

    private String text = "what's this";

    static {
        System.out.println("父类-static");
    }

    public InterviewQuestion() {
        System.out.println("父类-构造");
        show();
    }

    public void show() {
        System.out.println("父类-show");
        System.out.println(text);
    }

    static class InterviewAnswer extends InterviewQuestion {
        private String text = "this is answer";

        static {
            System.out.println("子类-static");
        }

        public InterviewAnswer() {
            System.out.println("子类-构造");
            show();
        }

        public void show() {
            //super.show(); //如果子类同名方法调用父类的同名方法，则父类初始化时就会同时执行父类方法和子类方法
            System.out.println("子类-show");
            System.out.println(text);
        }
    }

    //父类静态块-->子类静态块-->父类初始化语句-->父类构造器-->子类初始化语句-->子类构造器
    public static void main(String[] args) {
        new InterviewAnswer();
    }


}
